import { reqOrderInfo, reqAllOrderInfo, reqOrderDetail, delOrderInfo, reqOrder, addOrder } from '@/api'
export default {
    actions: {
        async getAllOrderInfo({ commit }, data) {
            let res = await reqAllOrderInfo(data)
            // console.log(res)
            if (res.code == 200) {
                commit('GETALLORDERINFO', res.results)
            }
        },
        async getOrderInfo({ commit }, data) {
            let res = await reqOrderInfo(data)
            // console.log(res)
            if (res.code == 200) {
                commit('GETORDERINFO', res.results)
            }
        },
        async getOrderDetail({ commit }, data) {
            let res = await reqOrderDetail(data)
            // console.log(res)
            if (res.code == 200) {
                commit('GETORDERDETAIL', res.results[0])
            }
        },
        async delOrder({ commit }, data) {
            let res = await delOrderInfo(data)
            // console.log(res)
        },
        async searchOrder({ commit }, data) {
            let res = await reqOrder(data.uid, data.kw)
            console.log(res)
            if (res.code == 200) {
                commit('SEARCHORDER', res.results)
            }
        },
        async addOrder({ commit }, data) {
            let res = await addOrder(data)
            console.log(res)
            if (res.code == 200) {
                // commit('ADDORDER', res.results)
            }
        },
    },
    mutations: {
        GETALLORDERINFO(state, data) {
            state.orderList = data
        },
        GETORDERINFO(state, data) {
            state.orderList = data
        },
        GETORDERDETAIL(state, data) {
            state.orderDetail = data
        },
        SEARCHORDER(state, data) {
            state.orderList = data
        }
    },
    state: {
        orderList: [],
        orderDetail: {},
    },
    getters: {
    },
    modules: {
    }
}